﻿using System.Diagnostics.CodeAnalysis;
using Microsoft.Practices.Unity;
using TrackIT.Common.Repositories;
using TrackIT.Common.Providers;
using System.IO;

namespace TrackIT.Common
{
    [ExcludeFromCodeCoverage]
    public static class TrackITContainer
    {
        public static IUnityContainer Current { get; set; }

        static TrackITContainer()
        {
            TrackITBaseConfigurationSection config = TrackITConfigurationSection.GetSection();

            Current = new UnityContainer()
                .RegisterType<IFileAccessRepository, FileAccessRepository>()
                .RegisterType<IDateTimeProvider, DateTimeProvider>()
                .RegisterType<FileSystemWatcher, FileSystemWatcher>()
                .RegisterType<IWorkLogRepository, WorkLogRepository>()
                .RegisterType<IEmailProvider, EmailProvider>()
                .RegisterType<IFileChangeNotifyProvider, FileChangeNotifyProvider>()                
                .RegisterInstance(typeof(string), "TaskPrefix", config.TaskPrefix)
                .RegisterInstance(typeof(string), "WorkFilename", config.WorkFilename)
                .RegisterInstance(typeof(bool), "DetectWorkFileChange", config.DetectWorkFileChange)                ;
        }
    }
}
